home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_206 / stereodemo / sources / window2.asm < prev    next >
Assembly Source File  |  1992-05-06  |  5KB  |  270 lines

  1.     INCLUDE "include:exec/types.i"
  2.     INCLUDE    "Stereo.i"
  3.  
  4.     XREF    _AbsExecBase
  5.     XREF    _LVOOpenWindow
  6.     XREF    _LVOCloseWindow
  7.     XREF    _LVOOpenLibrary
  8.     XREF    _LVOCloseLibrary
  9.     XREF    _LVOAllocMem
  10.     XREF    _LVOFreeMem
  11.     XREF    _LVODelay
  12.     XREF    _LVOMove
  13.     XREF    _LVODraw
  14.     XREF    _LVOSetAPen
  15.     XREF    _LVOWritePixel
  16.     XREF    _LVOGetPrefs
  17.     XREF    _LVOWindowToBack
  18.     XREF    _LVOText
  19.     XREF    _LVOSetDrMd
  20.  
  21. CLEAR_PUBLIC    EQU    MEMF_CHIP!MEMF_CLEAR
  22. MyFlag    EQU    SMART_REFRESH!WINDOWDEPTH!WINDOWDRAG
  23.  
  24. MLP1    EQU    33
  25. SWidth    EQU    340
  26. FullH    EQU    100
  27. Begin:    move.l    a6,-(a7)
  28.     move.l    a7,InitSP
  29.     bsr    LibsOpen
  30.     bsr    Prefs
  31.     bsr    OpenNew
  32.     bsr    DoGraphs
  33.     bsr    CloseNew
  34.     bsr    CloseLibs
  35.     move.l    InitSP,a7
  36.     move.l    (a7)+,a6
  37.     rts
  38. Prefs:
  39.     move.l    a6,-(a7)
  40.     move.l    #pf_SIZEOF,d0
  41.     bsr    StructureAlloc        ;Make space for preferences
  42.     move.l    IntuitionLibrary,a6
  43.     move.l    d0,a0            ;Point to space
  44.     move.l    a0,-(a7)
  45.     move.l    #pf_SIZEOF,d0        ;Get all of them
  46.     jsr    _LVOGetPrefs(a6)
  47.     move.l    (a7)+,a1
  48.     move.b    pf_LaceWB(a1),d0    ;Get lace status
  49.     cmp.b    #1,d0            ;See if interlace set
  50.     bne.s    NoInter
  51.     move.w    #FullH,d0
  52.     asl.w    #1,d0            ;Double for interlace
  53.     move.w    d0,SHeight
  54. NoInter:
  55.     move.l    #pf_SIZEOF,d0
  56.     bsr    StructFree
  57.     move.l    (a7)+,a6
  58.     rts
  59. InitNewWindow:
  60.     move.l    MyNewWindow,a2
  61.     move.w    #290,nw_LeftEdge(a2)
  62.     move.w    SHeight,d0
  63.     lsl.w    #1,d0
  64.     sub.w    #17,d0
  65.     move.l    #MyFlag,nw_Flags(a2)
  66.     move.w    #16,nw_TopEdge(a2)
  67.     move.w    #SWidth,nw_Width(a2)
  68.     move.w    d0,nw_Height(a2)
  69.     move.b    #3,nw_DetailPen(a2)    ;Green
  70.     move.b    #2,nw_BlockPen(a2)    ;Black
  71.     move.w    #SWidth,nw_MinWidth(a2)
  72.     move.w    d0,nw_MinHeight(a2)
  73.     move.w    #SWidth,nw_MaxWidth(a2)
  74.     move.w    d0,nw_MaxHeight(a2)
  75.     move.w    #WBENCHSCREEN,nw_Type(a2)
  76.     rts
  77. OpenNew:
  78.     move.l    #nw_SIZE,d0
  79.     bsr    StructureAlloc
  80.     move.l    d0,a2
  81.     bne.s    SucAll
  82.     bra    TotFail    ;Can't display if not to this point.
  83. SucAll:    move.l    a2,MyNewWindow
  84.     bsr.s    InitNewWindow    ;Initialize new window structure
  85.     move.l    MyNewWindow,a0
  86.     movea.l    IntuitionLibrary,a6    ;a6 established by IntuOpen
  87.     jsr    _LVOOpenWindow(a6)  ;Open the new window.
  88.     move.l    d0,MyWindow    ;Pointer to window structure for new window
  89. TotFail:
  90.     rts
  91. CloseNew:
  92.     move.l    a6,-(a7)
  93.     movea.l    MyWindow,a0
  94.     movea.l    IntuitionLibrary,a6
  95.     jsr    _LVOCloseWindow(a6)
  96.     move.l    _AbsExecBase,a6
  97.     move.l    MyNewWindow,a1
  98.     move.l    #nw_SIZE,d0
  99.     bsr    StructFree
  100.     move.l    #0,MyNewWindow
  101.     move.l    (a7)+,a6
  102.     rts
  103. StructureAlloc:
  104.     move.l    a6,-(a7)    ;Save a6 (intution library base)
  105.     move.l    _AbsExecBase,a6    ;Exec functions coming up
  106.     move.l    #CLEAR_PUBLIC,d1    ;Public memory
  107.     jsr    _LVOAllocMem(a6)
  108.     move.l    (a7)+,a6    ;Recover a6
  109.     rts
  110. StructFree:
  111.     move.l    a6,-(a7)
  112.     move.l    _AbsExecBase,a6
  113.     move.l    a1,d1
  114.     beq.s    IsFree
  115.     jsr    _LVOFreeMem(a6)
  116. IsFree:    move.l    (a7)+,a6
  117.     rts
  118. *OpenLib opens the library whose name is pointed to by a1.  The library
  119. *base address is returned in d0.  a6 is destroyed.
  120. OpenLib:
  121.     move.l    #MLP1,d0        ;Version 33 or later
  122.     movea.l    _AbsExecBase,a6
  123.     jsr    _LVOOpenLibrary(a6)    ;Find Library base.
  124.     rts                ;Library base returned in d0
  125. LibsOpen:
  126. *Now open intuition    
  127. IntuOpen:
  128.     move.l    #IntuitionName,a1    ;Request intuition library.
  129.     bsr.s    OpenLib
  130.     move.l    d0,IntuitionLibrary
  131.     beq    TotFail
  132. GraphicsOpen:
  133. * Open the graphics library
  134.     move.l    #GraphicsName,a1     ;Request graphics library.
  135.     bsr.s    OpenLib
  136.     move.l    d0,GraphicsLibrary    ;Save pointer
  137.     beq    TotFail
  138. GraphOpen:
  139.     move.l    #DosName,a1
  140.     bsr.s    OpenLib
  141.     move.l    d0,DosLibrary
  142.     beq    TotFail
  143.     rts
  144. CloseLibs:
  145.     move.l    _AbsExecBase,a6        ;Be certain we have exec library
  146.     move.l    DosLibrary,a1
  147.     bsr    CloseLib
  148.     move.l    GraphicsLibrary,a1
  149.     bsr    CloseLib        ;Close graphics library
  150.     move.l    IntuitionLibrary,a1
  151.     bsr    CloseLib        ;Close intuition library
  152.     rts
  153. CloseLib:
  154.     move.l    a1,d0
  155.     beq.s    NotOpen
  156.     jsr    _LVOCloseLibrary(a6)
  157. NotOpen:
  158.     rts
  159. DoGraphs:
  160.     move.l    a6,-(a7)
  161.     move.l    GraphicsLibrary,a6
  162.     move.l    MyWindow,a1
  163.     move.l    wd_RPort(a1),a1    ;Get rasterport
  164.     move.l    a1,MyRP
  165.     move.l    #2,d0
  166.     jsr    _LVOSetAPen(a6)    ;Set back to black
  167.     move.l    #0,d1
  168.     move.w    SHeight,d3
  169.     subq.w    #1,d3
  170.     ext.l    d3
  171.     move.l    #1,d4
  172.     bsr.s    ClrLin
  173.     move.l    MyRP,a1
  174.     move.l    #3,d0
  175.     jsr    _LVOSetAPen(a6)
  176.     move.l    MyRP,a1
  177.     move.l    #5,d0
  178.     move.l    #16,d1
  179.     jsr    _LVOMove(a6)
  180.     move.l    MyRP,a1
  181.     move.l    #0,d0        ;Jam 1
  182.     jsr    _LVOSetDrMd(a6)
  183.     move.l    MyRP,a1
  184.     lea    String,a0
  185.     lea    StrEnd,a2
  186.     sub.l    a0,a2
  187.     move.l    a2,d0
  188.     jsr    _LVOText(a6)
  189.     move.l    MyRP,a1
  190.     move.l    #1,d0        ;Jam 1
  191.     jsr    _LVOSetDrMd(a6)
  192.     move.l    #50,d5        ;55 0.4 s delays
  193.     bsr    DoDelay
  194.     move.l    MyRP,a1
  195.     move.l    #0,d2
  196.     move.w    SHeight,d3
  197.     subq.w    #4,d3
  198.     ext.l    d3
  199. DoLine:    move.l    #SWidth,d0
  200.     move.w    SHeight,d1
  201.     ext.l    d1
  202.     asr.l    #1,d0
  203.     asr.l    #2,d1
  204.     movem.l    d0-d1/a1,-(a7)
  205.     jsr    _LVOMove(a6)
  206.     movem.l    (a7)+,d0-d1/a1
  207.     move.l    d2,d0
  208.     move.l    d3,d1
  209.     movem.l    d0-d1/a1,-(a7)
  210.     jsr    _LVODraw(a6)
  211.     moveq.l    #1,d5        ;1 0.4 s delay between lines
  212.     bsr    DoDelay
  213.     movem.l    (a7)+,d0-d1/a1
  214.     addq.l    #8,d2
  215.     cmp.l    #SWidth-4,d2
  216.     blt.s    DoLine
  217.     move.l    (a7)+,a6
  218.     move.l    #265,d5
  219.     bsr.s    DoDelay
  220.     rts
  221. ClrLin:    movem.l    d1/a1,-(a7)
  222.     move.l    d4,d0
  223.     jsr    _LVOMove(a6)
  224.     movem.l    (a7)+,d1/a1
  225.     movem.l    d1/a1,-(a7)
  226.     move.l    #SWidth-1,d0
  227.     jsr    _LVODraw(a6)
  228.     movem.l    (a7)+,d1/a1
  229.     addq.l    #1,d1
  230.     subq.l    #1,d3
  231.     bne.s    ClrLin
  232.     rts
  233. DoDelay:
  234.     movem.l    d1/a6,-(a7)
  235. SrtDel:    move.l    #20,d1        ;Allow 1/2 s per loop
  236.     move.l    DosLibrary,a6
  237.     jsr    _LVODelay(a6)
  238.     subq.l    #1,d5        ;Count down outer loop
  239.     bne.s    SrtDel
  240.     movem.l    (a7)+,d1/a6
  241.     rts
  242.  
  243.     dseg
  244.  
  245. InitSP:    dc.l    0
  246. MyRP:    dc.l    0
  247. MyNewWindow:
  248.     dc.l    0
  249. MyWindow:
  250.     dc.l    0
  251. IntuitionLibrary:
  252.     dc.l    0
  253. GraphicsLibrary:
  254.     dc.l    0
  255. DosLibrary:
  256.     dc.l    0
  257. SHeight:
  258.     dc.w    100
  259. IntuitionName:
  260.     dc.b    'intuition.library',0
  261. GraphicsName:
  262.     dc.b    'graphics.library',0
  263. DosName:
  264.     dc.b    'dos.library',0
  265. String:
  266.     dc.b    '  A>  Spreadsheets R us.'
  267. StrEnd:    dc.b    0
  268.     END
  269.  
  270.